#pragma once

#include <QWidget>
#include <memory>
#include <QVector>


#include "ui_CDUTSettingDlg.h"
#include "CBaseWidget.h"
#include "CNormalMarco.h"



class QTcpSocket;
class QTimer;
class CShowTraceWidget;


typedef struct tag_trace_info_show
{
	QString str_id;
	QString str_x_axis;
	QString str_y_axis;
	QString str_x_speed;
	QString str_y_speed;
	tag_trace_info_show()
		:str_id{}
		,str_x_axis{}
		,str_y_axis{}
		,str_x_speed{}
		,str_y_speed{}
	{}
}TraceShow;

class CDUTSettingDlg final: public QWidget
{
	Q_OBJECT
signals:
	void sig_send_points(QVector<QPointF>& _vec);
private slots:
	void OnReadDatagram();
	void OnConnectInform();
	void OnDisconnectInform();
	
	void OnTimerProc();
	void on_pushButton_start_clicked();
public:
	CDUTSettingDlg(QWidget *parent = Q_NULLPTR);
	~CDUTSettingDlg();
private:
	void OnInitDialog()noexcept;
	void InitSlot()noexcept;
	void InitTcpSocket()noexcept;
	void InitTimer()noexcept;
	void InitCheckData();
	void InitTableWidget()noexcept;
	//
	void LoadNetworkCfg()noexcept;
	int SendVersionCheckDatagram();
	int SendTraceDatagram();
	int ParseVersionData(char* buf, int len);
	int ParseTraceData(char *buf,int len);
	void SaveRadarTraceData(char *buf,int num);
	void DemonstrateObjDetail();
	void CleanTable()noexcept;
private:
	std::unique_ptr<QTcpSocket>m_spSocket;
	QString m_ip;
	int m_port;
	bool m_connect_flag;
	std::unique_ptr<QTimer>m_spTimer;
	U16 m_version_checked;
	QVector<TraceShow>m_trace_container;
private:
	Ui::CDUTSettingDlg ui;
};
